<template>
  <view class="modal-overlay" @click="close">
    <view class="modal" @click.stop style="position: relative;">
		
      <view class="modal-header">{{ title }}</view>
      <view class="modal-body">
        <slot></slot> <!-- 插槽，用于传递自定义内容 -->
		<view @click="close()" class="cuIcon-close close_btn"></view>
      </view>
      <view class="modal-actions" v-if="showBtn == true">
		  <button class="cu-btn round bg-grey" style="padding: 16rpx 60rpx;" @click="close">{{ cancelText }}</button>
        <button class="cu-btn round bg-blue margin-right-xs" style="padding: 16rpx 60rpx;" @click="confirm">{{ confirmText }}</button>
        
      </view>
    </view>
  </view>
</template>

<script>
export default {
	name : 'Modal',
  props: {
	showBtn: {
	    type: Boolean,
	    required: false,
		default : true
	},
    title: {
      type: String,
      required: true,
    },
    confirmText: {
      type: String,
      default: '确定',
    },
    cancelText: {
      type: String,
      default: '取消',
    },
  },
  methods: {
    close() {
      this.$emit('close');
    },
    confirm() {
      this.$emit('confirm');
    },
  },
};
</script>

<style scoped>

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99;
}

.modal {
background: linear-gradient(to bottom, #e0f2ff, #f8f8ff);
  padding: 20rpx;
  border-radius: 10rpx;
  width: 90%;
  padding-top: 50rpx;
  z-index: 100;
 
}
.close_btn{
	font-size: 38rpx;
	top: 0;
	right: 0;
}
.modal-header {
  font-size: 32rpx;
  margin-bottom: 20rpx;
  text-align: center;
}

.modal-body {
  margin-bottom: 30rpx;
}

.modal-actions {
  display: flex;
  justify-content: space-around;
}
.close_btn {
	position: absolute;font-size: 40rpx;right: 30rpx;top: 30rpx;
}
</style>
